package com.example.tms.mapper;

import com.example.tms.bean.OfficeInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 办公室报账
 */
public interface OfficeMapper extends JpaRepository<OfficeInfo, String>, JpaSpecificationExecutor<OfficeInfo> {


    //查询报账信息（报账id）
    @Query(value = "select * from office_info where bgsbzid = ?1 and sfcz = true", nativeQuery = true)
    OfficeInfo findByBgsbzid(String bgsbzid);

    //查询报账信息（报账日期）
    List<OfficeInfo> findByRiqiAndSfcz(String riqi, boolean sfcz);

    //删除报账信息（假删除 报账id）
    @Query(value = "update office_info set sfcz = false where bgsbzid = ?1", nativeQuery = true)
    @Modifying
    @Transactional
    void DeleteByBgsbzid(String bgsbzid);
}